package com.itqf.controller;

import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

/**
 * projectName: springmvcgp8
 *
 * @author: 赵伟风
 * time: 2021/8/6 17:49
 * description:
 */
@RestController
@RequestMapping("file")
@CrossOrigin("*")
public class FileController {

    @PostMapping("upload")
    public String upload(MultipartFile file,String username) throws IOException {

        String originalFilename = file.getOriginalFilename();
        String name = file.getName();


        file.transferTo(new File("D:\\temp\\"+originalFilename));

        return originalFilename+"::"+name+"::"+username;

    }

}
